package com.advertising.biz;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.beanutils.BeanUtils;
import org.springframework.stereotype.Service;

import com.advertising.dao.EvaluateDAO;
import com.advertising.model.CloneEvaluate;
import com.advertising.model.Evaluate;
import com.tgyt.common.tools.page.Pagination;
import com.tgyt.framework.dao.hspring.DAOInterface;
import com.tgyt.framework.service.BaseService;
@Service
public class EvaluateService extends BaseService<Evaluate> implements IEvaluateService {
	@Resource(name= "evaluateDAO")
	private EvaluateDAO evaluateDAO;
	@Override
	protected DAOInterface<Evaluate> getDAO() {
		 
		return evaluateDAO;
	}
	@Override
	public Pagination getPageList(Evaluate evaluate, int page, int rows,
			String sort, String order) {
		return 	this.evaluateDAO.getPageList(evaluate, page, rows, sort, order);
	}
	@Override
	public List<CloneEvaluate> convert(List<Evaluate> evaluate) throws Exception {
		List<CloneEvaluate> evaluates = new ArrayList<CloneEvaluate>();
		/* DictionaryMemoryUtils dictionaryUtils = DictionaryMemoryUtils.getInstance();
		    Map maps = (Map)dictionaryUtils.getDictionarysMap().get("advertype");*/
		    
		if(evaluate!=null && evaluate.size()!=0){
			for(Iterator<Evaluate> iter=evaluate.iterator();iter.hasNext();){
				Evaluate res = iter.next();
				CloneEvaluate c = new CloneEvaluate();
				BeanUtils.copyProperties(c, res);
				if(res.getUserId()!=null){
					c.setUserid(res.getUserId().getId()+"");
					c.setAdvername(res.getUserId().getAdvername());
					c.setInternaluri(res.getUserId().getInternaluri());
					c.setExternaluri(res.getUserId().getExternaluri());
					c.setAddress(res.getUserId().getAddress());
					c.setPidouid(res.getUserId().getPidouid());
					c.setPhone(res.getUserId().getPhone());
					c.setAdvertype(res.getUserId().getAdtype());
					c.setCoordinate(res.getUserId()+" , "+res.getUserId());
					
				}
				/*if (res.getApprove()!=null) {
					c.setClickprice(res.getApprove().getClickprice());//单次点击金额
				}*/
				
				 
				evaluates.add(c);
			}
		}
		return evaluates;
	}

}
